#include "screen.h"

#include <stdio.h>

//----------------------------------------------------------------------

Screen::Screen() {
	for( int i = 0; i < HEIGHT; i++ ) {
		for( int j = 0; j < WIDTH; j++ ) {
			screen[i][j] = ' ';
		}
	}
}

//----------------------------------------------------------------------
		
void Screen::set( int x, int y, char c ) {
	screen[y][x] = c;
}
	
//----------------------------------------------------------------------

char Screen::get( int x, int y ) {
	return screen[y][x];
}
	
//----------------------------------------------------------------------
		
void Screen::setBall( int x, int y ) {
	static int oldX, oldY;
	
	screen[oldY][oldX] = ' ';
	screen[y][x] = '*';
	oldX = x;
	oldY = y;
}

//----------------------------------------------------------------------

void Screen::setLine( int y, bool left ) {
	int x;
	if( left == true ) x = 0;
	else x = 79;
	
	for( int i = 0; i < HEIGHT; i++ ) {
		screen[i][x] = ' ';
	}
	
	for( int i = 0; i < LINE; i++ ) {
		screen[y+i][x] = '|';
	}
}

//----------------------------------------------------------------------
		
void Screen::print() {
	for( int i = 0; i < HEIGHT; i++ ) {
		for( int j = 0; j < WIDTH; j++ ) {
			putchar( screen[i][j] );
		}
		printf("\n");
	}
} 

//----------------------------------------------------------------------
